import React, { Component } from 'react';
import { View, Image } from '@tarojs/components';
import {
    GET_APP_ADVERT_IMG,
} from '../../constants/api';
import {http} from '../../utils/http'
import {user} from "../../utils/user.service";

class Advertisement extends Component {
    state: any = {
        imageData: {

        }
    }
    async UNSAFE_componentWillMount() {
      if (await user.checkLogin()) {
        const image = await http.HPost(GET_APP_ADVERT_IMG, {});
        this.setState({
          imageData: image.data
        })
        }
    }
    render() {
        const { imageData } = this.state;
        return (
            <View>
                {
                    imageData.is_open == 1 &&
                        <Image src={imageData.advert_img} style='width: 100%;' mode='widthFix' />
                }
            </View>
        )
    }
}
export default Advertisement;
